package com.lopo;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
public class FunctionDemo {
    public static void main(String[] args) {
        List<Student> list = new ArrayList();
        list.add(new Student("Ram",20));
        list.add(new Student("Shyam",22));
        list.add(new Student("Kabir",18));

        //Style one to declare function 
        Function<Student,String> styleOne = s->{
            String result =  "Name:"+s.name +" and Age:"+s.age;
            return result;
        };

        //print the values of list using stle one function
        for(Student st: list){
            System.out.println(customShow(st,styleOne));
        }


    }

    public static String customShow(Student student,Function<Student,String> fun){
        return fun.apply(student);
    }
}


 class Student {
    public String name;
    public int age;
    public Student(String name,int age){
        this.name = name;
        this.age = age;
    }

}

